package com.github.fancyideas.generator;

import com.github.fancyideas.utils.IdUtil;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentityGenerator;

import java.io.Serializable;

public class CustomIdGen extends IdentityGenerator {
    @Override
    public Serializable generate(SharedSessionContractImplementor s, Object obj) {
        long id = IdUtil.nextId();
        if (id != 0) {
            return id;
        }
        return super.generate(s, obj);
    }
}
